
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>经济管理学院</title>
<link rel="stylesheet" href='css/style.css' type="text/css">

</head>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript' src='js/public.js'></script>
<script type="text/javascript">
	function showuserkey() {
		var params = "user_keyName=userName";
		new Ajax.Request("json/showUser_key", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();

				if (res["result"]["userName"] == null)
					window.location.href = "login.html";
				document.getElementById("username").innerHTML = "欢迎 "
						+ res["result"]["userName"];
			},
			asynchronous : true
		});
		online();
		showAllRegisterLecture();
		iteratorLectures();
	}

	function showAllRegisterLecture() {
		var params = "";
		new Ajax.Request("json/showAllRegisterLecture", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();
				
			
				for (var i = 0; res["result"]["lecname" + i] != null; i++) {
				var nohtml="<li>"+res["result"]["lecname"+i]+"</li>";
				
				$("regis").innerHTML += nohtml;}
			},
			asynchronous : true
		});
		showAllCheckLecture();
	}
	
	function showAllCheckLecture() {
		var params = "";
		new Ajax.Request("json/showAllCheckLecture", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();
				
				
				for (var i = 0; res["result"]["lecname" + i] != null; i++) {
				var nohtml="<li>"+res["result"]["lecname"+i]+"</li>";
				
				$("no").innerHTML += nohtml;}
			},
			asynchronous : true
		});
	}
	


	function viewLecturesOutline(productId) {

		var params = "lectureId=" + productId;
		new Ajax.Request(
				"json/viewLecturesOutline",
				{
					method : "post",
					parameters : params,
					onComplete : function(request) {
						var res = request.responseText.evalJSON();
						//alert(res["result"]["flag"]);
						if (res["result"]["flag"] == "true") {
							var grade = " ";
							if (res["result"]["userEnterYear1"] !== null)
								grade += res["result"]["userEnterYear1"] + " ";
							if (res["result"]["userEnterYear2"] !== null)
								grade += res["result"]["userEnterYear2"] + " ";
							if (res["result"]["userEnterYear3"] !== null)
								grade += res["result"]["userEnterYear3"] + " ";
							if (res["result"]["userEnterYear4"] !== null)
								grade += res["result"]["userEnterYear4"] + " ";
							var start = compareTime(res["result"]["startTime"]);
							var stop = compareTime(res["result"]["stopTime"]);

							var status = "";
							if (start == "大于")
								status += "未到报名时间" + res["result"]["startTime"];
							if (start == "小于" & stop == "大于")
								status += "正在报名中 截止时间"
										+ res["result"]["stopTime"];
							if (stop == "小于")
								status += "报名已经截止";
							var tmp = "<ul style='width:100%; border-bottom:1px  #999 dotted;'><li style='margin-left:20px; margin-top:20px;'><a href='StuOperateLecture.html?lectureId="
									+ res["result"]["lectureId"]
									+ "'>主题："
									+ strShorten(res["result"]["lecName"],40)
									+ " (点击进行更多操作)</a></li><li style='margin-left:20px;'>主讲人："
									+ res["result"]["lecSpeaker"]
									+ "</li><li style='margin-left:20px;'>举办时间："
									+ res["result"]["lecTime"]
									+ "</li><li style='margin-left:20px;'>举办地点："
									+ res["result"]["lecPlace"]
									+ "</li><li style='margin-left:20px;''>参与年级："
									+ grade
									+ "</li><li style='margin-left:20px;''>备注："
									+ res["result"]["lecNote"]
									+ "</li><li style='margin-left:20px;'>状态："
									+ status + "</li></ul>";
							$("iteratorProductsTarget").innerHTML += tmp;
							document.getElementById("username").innerHTML = "欢迎 "
									+ res["result"]["uname"];
						}
					},
					asynchronous : false
				});
	}
	function iteratorLectures() {

		var request = {
			QueryString : function(val) {
				var uri = window.location.search;
				var re = new RegExp("" + val + "=([^&?]*)", "ig");
				return ((uri.match(re)) ? (uri.match(re)[0]
						.substr(val.length + 1)) : null);
			}
		};
		var max = request.QueryString("max");
		var first = request.QueryString("first");
		if (max == null || first == null) {
			max = 3;
			first = 0;
		}
		var curpage = request.QueryString("curpage");
		if (curpage == null)
			curpage = 1;

		var params = "max=" + max + "&first=" + first;
		new Ajax.Request(
				"json/iteratorLectures",
				{
					method : "post",
					parameters : params,
					onComplete : function(request) {
						var res = request.responseText.evalJSON();
						if (res["result"]["flag"] == "true") {
							for ( var i = 0; res["result"]["LectureId" + i] != null; i++) {
								viewLecturesOutline(res["result"]["LectureId"
										+ i]);
							}

							var amount = res["result"]["amountOfLectures"];
							var CountPage = parseInt(amount / max);
							if (amount % max > 0)
								CountPage++;
							var nextpage = parseInt(curpage) + 1;
							var prepage = parseInt(curpage) - 1;
							var last = (CountPage - 1) * max;
							document.getElementById("amountOfLectures").innerHTML = "共"
									+ amount + "条记录";
							document.getElementById("CountPage").innerHTML = "分"
									+ CountPage + "页";
							document.getElementById("curpage").innerHTML = "当前第"
									+ curpage + "页";
							document.getElementById("firstPage").innerHTML = "<a href='StudentIndex.html?max="
									+ max
									+ "&first="
									+ 0
									+ "&curpage="
									+ 1
									+ "' >第一页</a>";
							document.getElementById("lastPage").innerHTML = "<a href='StudentIndex.html?max="
									+ max
									+ "&first="
									+ last
									+ "&curpage="
									+ CountPage + "' >尾页</a>";

							var next = parseInt(first) + parseInt(max) >= parseInt(amount) ? parseInt(amount)
									- parseInt(max)
									: parseInt(first) + parseInt(max);
							var previous = parseInt(first) - parseInt(max) <= 0 ? 0
									: parseInt(first) - parseInt(max);
							if (prepage > 0)
								document.getElementById("previous").innerHTML = "<a href='StudentIndex.html?max="
										+ max
										+ "&first="
										+ previous
										+ "&curpage="
										+ prepage
										+ "' >上一页</a>&nbsp";
							if (nextpage <= CountPage)
								document.getElementById("next").innerHTML = "<a href='StudentIndex.html?max="
										+ max
										+ "&first="
										+ next
										+ "&curpage="
										+ nextpage + "' >下一页</a>&nbsp";

						}
					},
					asynchronous : false
				});

	}
	
</script>
<body onload="showuserkey()">
	<div id="header">

		<div id="nav">
			<ul
				style="float: left; padding: 0 20px; text-align: center; line-height: 50px;">
				<li style="float: left; font-size: 28px">经管院学术讲坛事务系统</li>
			</ul>
			<ul class="horizon">

				<li class="login">
					<ul class="vertical">
						<li class="userInfo" id="username">&nbsp;你好</li>
						<li class="userInfo2">
							<ul class="horizon">

								<li><a href="editorUser.html" target="_blank"
									style="text-decoration: none;">个人资料</a><br />
								<a onclick="outline()" style="text-decoration: none;" href="#">注销</a></li>
							</ul>
						</li>
					</ul>
				</li>

			</ul>
		</div>




	</div>
	<div id="main">
		<div
			style="width: 21%; height: 660px; border-right: 3px #660033 solid; float: left; background-color: rgb(242, 247, 252);">
			<div style="width: 100%; margin-top: 50px;">

				<ul style="margin-left: 20px;" id="no">已听的讲座：
				</ul>
				<ul style="margin-left: 20px; margin-top: 20px" id="regis">参与报名的讲座:
				</ul>

			</div>
		</div>
		<div style="width: 78%; font-size: 22px; float: right">
			<div style="margin-top: 50px; margin-left: 50px; height: 560px">
				<table width="800" border="0"
					style="font-size: 14px; border: 2px solid #999;">
					<tr>
						<td style="border-bottom: 1px #999 dotted;">
							<li id="firstPage"
							style="float: left; width: 50px; margin-left: 150px;"></li>
							<li id="previous" style="float: left; width: 50px"></li>



							<li id="next" style="float: left; width: 50px;"></li>
							<li id="lastPage" style="float: left; width: 50px"></li>
							<li id="amountOfLectures" style="float: left; width: 80px"></li>
							<li id="CountPage" style="float: left; width: 50px"></li>
							<li id="curpage" style="float: left; width: 80px"></li>
						</td>
					</tr>
					<tr>
						<td style="font-size: 16px;"><div id="iteratorProductsTarget">

							</div></td>
					</tr>
				</table>


			</div>
			<div style="font-size: 14px; margin-left: 100px;">
				<span id="online">当前在线人数:</span> <span style="margin-left: 150px">Copyright
					&copy; 2013 经济管理学院 北京市海淀区清华东路35号 邮编：100083</span>
			</div>
		</div>

	</div>

</body>
</html>
